package com.damon.utils;

import java.util.ArrayList;
import java.util.HashMap;

import com.damon.Entity.WcsDvcEntity;
import com.damon.window.WcsWindow;

/**
 * ps:用来保存一些公共对象实例
 * @author 风蚕
 *
 */
public class GlobalOjbectUtil {
	
public static WcsWindow window;//java可视化实例对象
public static ArrayList<String> dvcList = new ArrayList<>();//设备号上线状态
public static HashMap<String, Integer> dvcCountMap = new HashMap<>();//设备处理报文计数
public static HashMap<String, Boolean> socketIsLiveMap = new HashMap<>();//记录socket是否关闭

public static WcsWindow getWindow() {
	return window;
}

public static void setWindow(WcsWindow wcsWindow) {
	window = wcsWindow;
}

public static ArrayList<String> getDvcList(){
	return dvcList;
}

/**
 * ps:向状态栏中添加设备号
 */
public static void addDvcNo(String dvcNo) {
	dvcList.add(dvcNo);
	window.getDvcStatus().setText("已连接设备："+dvcList.size()+"个："+dvcList.toString());
}
/**
 * ps:在状态栏中将设备号移除
 */
public static void removeDvcNo(String dvcNo) {
	dvcList.remove(dvcNo);
	window.getDvcStatus().setText("已连接设备："+dvcList.size()+"个："+dvcList.toString());
}

public static HashMap<String, Integer> getDvcConuntMap(){
	return dvcCountMap;
}
/**
 * ps:向状态栏中增加设备处理报文数
 */
public static void addDvcCountToMap(String key,Integer count) {
	dvcCountMap.put(key, count);
	window.getCountStatus().setText("设备计数："+dvcCountMap);
}

/**
 * ps:添加socket存活状态
 * @param wcsDvcEntity
 * @param isLive
 */
public static void addSocketIsLive(WcsDvcEntity wcsDvcEntity,Boolean isLive) {
	socketIsLiveMap.put(wcsDvcEntity.getDvcNo(), isLive);
}

/**
 * ps:获取socket存活状态
 * @param wcsDvcEntity
 * @return
 */
public static Boolean getSocketIsLive(WcsDvcEntity wcsDvcEntity) {
	return socketIsLiveMap.get(wcsDvcEntity.getDvcNo());
}

}
